import React from 'react' 
import axios from 'axios'
import Robot from '../src/components/Robot'


export default class App extends React.Component {
    constructor(props) {
        super(props) 
        this.state = {
            list:[]
        }
    }

    // mounted
    componentDidMount() {
        console.log('组件渲染之后')

        axios({
            url:'https://jsonplaceholder.typicode.com/users',
            method:'get'
        }).then((res)=>{
            console.log('res',res)
            this.setState({
                list:res.data
            })
        }).catch(err=>{
            console.log('err')
        })

    }



    render() {
        return (
            <ul className='f1'>
                {
                    this.state.list.map((r)=>(
                     
                            <Robot
                            key={r.id}
                            id={r.id}
                            email={r.email}
                            name={r.name}
                        >
    
                        </Robot>
                    )
                    )
                }
            </ul>
        )
    }
}